home *** CD-ROM | disk | FTP | other *** search
- $! hcompress.com
- $!
- $! VMS command file to do H-transform image compression for a list of image
- $! files in .hhh, .hhd format. *.hhd files are replaced by *.hhd_H.
- $!
- $! Program will compress only I*2 images with no group parameters.
- $! (A warning is issued for other images.)
- $!
- $! The default compression scale factor is 666, which is appropriate for
- $! gasp images (gives about a factor of 10 compression, negligible loss in
- $! information.)
- $!
- $! R. White, 20 April 1992
- $!
- $! determine where this procedure lives (assume that the executable files
- $! are in this same directory)
- $!
- $ shellfile=f$parse(f$environment("procedure"),,,,"NO_CONCEAL")-"]["
- $ cdir=f$extract(0,f$locate("]",shellfile),shellfile) + "]"
- $ prgnam=f$parse(shellfile,,,"NAME")
- $!
- $ echo:=write sys$output
- $ hc:=$'cdir'hcomp
- $!
- $ if p1.eqs.""
- $ then
- $ echo "Usage: ",prgnam," [options] files... [options] files..."
- $ echo " where options are:"
- $ echo " -s scale to specify the compression scale factor"
- $ echo " -k to keep the uncompressed file (default)"
- $ echo " -r to remove the uncompressed file"
- $ echo ""
- $ echo "Default compression scale factor is 666 (good for GASP images.)"
- $ echo "Specify .hhd extension on files. Compressed files are named *.*_H."
- $ exit
- $ endif
- $!
- $ scale=666
- $ nextscale=0
- $ remove=0
- $ p=1
- $ ploop:
- $ parm = p'p
- $ if parm.eqs."" then exit ! all done
- $ if nextscale.eq.1
- $ then
- $ scale=parm ! set scale
- $ nextscale=0
- $ echo "Using scale ", scale
- $ goto endploop
- $ endif
- $ if parm.eqs."-S"
- $ then
- $ nextscale=1 ! next parm is scale
- $ goto endploop
- $ endif
- $ if parm.eqs."-R"
- $ then
- $ remove=1 ! remove original files
- $ goto endploop
- $ endif
- $ if parm.eqs."-K"
- $ then
- $ remove=0 ! keep original files
- $ goto endploop
- $ endif
- $!
- $! compress the file(s) specified by this parameter
- $! use f$search to allow the use of wildcards in file specifications
- $!
- $ datafile=f$search(parm,1) ! get original file name
- $ if datafile.eqs.""
- $ then
- $ echo prgnam,": ",datafile,": No such file"
- $ goto endploop
- $ endif
- $!
- $! save name of first file to correct the stupid behavior of f$search
- $! when the file argument does not contain a wildcard character
- $!
- $ firstfile=datafile
- $ floop:
- $ dext=f$parse(datafile,,,"TYPE")
- $ hext=f$extract(0,3,dext)+"H"
- $ headfile=f$parse(hext+";",datafile,,,"SYNTAX_ONLY") ! header name
- $ cext=dext+"_H"
- $ compfile=f$parse(cext+";",datafile,,,"SYNTAX_ONLY") ! compress name
- $!
- $! check that header file exists
- $! if compressed file already exists, we'll rely on VMS to create a new version
- $!
- $ if f$extract(3,1,dext).nes."D"
- $ then
- $ echo prgnam,": ",datafile," does not have .xxd extension"
- $ goto endfloop
- $ endif
- $ if f$search(headfile,2).eqs.""
- $ then
- $ echo prgnam,": ",headfile,": No such file"
- $ goto endfloop
- $ endif
- $!
- $! perform compression
- $!
- $ echo datafile
- $ define/user sys$output 'compfile'
- $ hc -v -s 'scale' -i hhh 'datafile' 'headfile'
- $ if $status.eq.1 ! check for success
- $ then
- $ if remove.eq.1 then delete 'datafile' ! delete original file
- $ else
- $ echo prgnam,": ",datafile," not compressed: compression error"
- $ delete 'compfile' ! delete compressed file
- $ endif
- $ endfloop:
- $!
- $! get next file name
- $!
- $! be careful: f$search returns the same name every time if there are
- $! no wildcard characters in the argument (dumb)
- $!
- $ datafile=f$search(parm,1)
- $ if datafile.nes.firstfile
- $ then
- $ if datafile.nes."" then goto floop
- $ endif
- $!
- $! go to next parameter
- $!
- $ endploop:
- $ p = p+1
- $ goto ploop
-